<?php

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('categories-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
$this->_toolbar = array(
		'title'		=>	Yii::t('admin_news', 'Categories Manager'),
		'buttons'	=>	array(
							CHtml::link(Yii::t('admin_news','Advanced Search'), "", array("id"=>"search", "class"=>"search-button button-s")),
		)
);
?>

<div class="search-form">
<?php $this->renderPartial('_search', array(
	'model' => $model,
)); ?>
</div><!-- search-form -->

<?php $this->widget('ext.widgets.iGridView', array(
	'id' => 'categories-grid',
	'dataProvider' => $model->search(),
	'filter' => $model,
	'columns' => array(
		array(
			'name'	=>	'id',
			'htmlOptions'	=>	array(
				'width'	=>	'30',
				'align'	=>	'center'
			)
		),
		array(
			'name'	=>	'title',
			'type'	=>	'raw',
			'value'	=>	'CHtml::link($data->title_tree,array("categories/update","id"=>$data->id), array("style"=>"text-decoration:none"))',
		),
		'alias',
		array(
			'name'	=>	'parent_id',
			'value'	=>	'Categories::model()->findByPk($data->parent_id)->title'
		),
		array(
			'name'	=>	'ordering',
			'htmlOptions'=>array(
				'width'	=>	30,
				'align'	=>	'center'
			)
		),
		/*
		'created_by',
		'modified',
		'modified_by',
		*/
		array(
			'name' => 'published',
			'type'	=>	'raw',
			'value' => '($data->published == 0) ? CHtml::image(Yii::app()->theme->baseUrl."/images/icons/Draft.png","unpublished") : CHtml::image(Yii::app()->theme->baseUrl."/images/icons/Published.png","Published",array("width"=>"21"))',
			'filter' => array('0' => Yii::t('app', 'No'), '1' => Yii::t('app', 'Yes')),
			'htmlOptions'	=>	array('align'=>'center')
			),
		array(
			'class' => 'CButtonColumn',
			'afterDelete'=>'function(link,success,data){if(data!="") alert(data); }'
		),
	),
)); ?>